﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Diagnostics;

namespace TextToHTML
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// User could care less and is ready for us to cancel the rendering
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelRendering(object sender, RoutedEventArgs e)
        {
            Close();
        }

        /// <summary>
        /// The user wants us to render the text to an html document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RenderText(object sender, RoutedEventArgs e)
        {
            Cursor oldCursor = Cursor;
            Cursor = Cursors.Wait;

            try
            {
                RenderHTMLTools rh = new RenderHTMLTools();
                App.ComposeMe(rh);
                FileInfo tempFile = rh.RenderText(toRenderText.Text);
                Process.Start(tempFile.FullName);
            }
            finally
            {
                Cursor = oldCursor;
            }
        }
    }
}
